<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
    <hello></hello>
    <school></school>
    <hr>
    <student></student>
</div>
<hr>
<hr>
<div id="root2">
    <hello></hello>
    <school></school>
    <hr>
    <student></student>
</div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false;
    const school = Vue.extend({
        template: `
          <div>
          <h2>学校名称：{{ name }}</h2>
          <h2>学校地址：{{ address }}</h2>
          <button @click="showName">点击提示学校名称</button>
          </div>
        `,
        data() {
            return {
                name: "abc",
                address: "深圳"
            }
        },
        methods: {
            showName() {
                alert(this.name);
            }
        },
    });
    const student = Vue.extend({
        template: `
          <div>
          <h2>学生姓名：{{ name }}</h2>
          <h2>学生年龄：{{ age }}</h2>
          </div>
        `,
        data() {
            return {
                name: "张三",
                age: 18
            }
        },
    });
    const hello = Vue.extend({
        template: `
          <div>Hello, {{ name }}</div>
        `,
        data() {
            return {
                name: 'Tom'
            }
        },
        computed: {},
        methods: {},
        watch: {},
        filters: {},
        directives: {}
    });
    Vue.component('hello', hello);
    new Vue({
        el: '#root',
        data() {
            return {
                msg: "Hello!"
            }
        },
        components: {
            school: school,
            student: student
        },
    });
    new Vue({
        el: '#root2',
        data() {
            return {}
        },
        computed: {},
        components: {
            school: school,
            student: student
        },
        methods: {},
        watch: {},
        filters: {},
        directives: {}
    });
</script>
</html>